<?php
/**
 * 退卡记录
 *
 * @auther 大耳牛
 * 2017-2-16
 **/
namespace Xijie\Model;
use Think\Model;
class HydropowerModel extends Model{
	//定义表名称
	protected $tableName = 'hydropower';
	
	/**
	 * 获取列表总数
	 *
	 **/
	public function getHydropowerCount($where){
		return $this->where($where)->count();
	}
	
	/**
	 * 获取列表
	 *
	 **/
	public function getHydropowerList($page, $where){
		return $this->where($where)
					->order('roomnumber/1 asc, month asc')
					->page($page, C('PAGE_SIZE'))
					->select();
	}
	
	public function getHydropowerAllLogList($where){
		return $this->alias('hydrop')
					->field('hydrop.*, member.btime, member.eqment_1,eqment_2,eqment_3')
					->join('left join momoda_member as member on hydrop.roomnumber = member.room_number and member.visible = 1')
					->where($where)
					->order('hydrop.roomnumber/1 asc')
					->select();
	}
	
	/**
	 * 查询全部
	 **/
	public function getHydropowerAllList($where){
		return M('hydropower_log')->where($where)->order('roomnumber/1 asc')->select();
	}
	
	public function getHydropowerLogInfo($where){
		return M('hydropower_log')->where($where)->find();
	}

	/**
	 * 添加
	 **/
	public function addHydropowerInfo($data){
		return $this->data($data)->add();
	}
	
	/**
	 * 批量添加
	 **/
	public function addHydropowerAll($data){
		return $this->addAll($data);
	}
	
	/**
	 * 获取数据详情
	 **/
	public function getHydropowerInfoById($id){
		return $this->where(array('id' => $id))->find();
	}
	
	/**
	 * 编辑数据详情
	 **/
	public function editHydropowerInfo($where=array(), $data=array()){
		return $this->where($where)->setField($data);
	}
	
	/**
	 * 根据房间号查询数据
	 **/
	public function getHydropowerInfoByRoomId($roomnumber, $month){
		return $this->where(array(
			'roomnumber' => $roomnumber,
			'month' => $month
		))->find();
	}
}